<?php

class clerk extends object_standard {

    //attribute variables 
    protected $document;
    protected $name;
    protected $salary;
    protected $boss;
    //components 
    var $components = array();
    //auxiliars for primary key and for files 
    var $auxiliars = array();

    //data about the attributes 
    public function metadata() {
        return array("id" => array(), "name" => array(), "salary" => array(),
            "boss" => array("foreign_name" => "b_p", "foreign" => "boss", "foreign_attribute" => "id"));
    }

    public function primary_key() {
        return array("id");
    }

    public function relational_keys($class, $rel_name) {
        switch ($class) {
            case "boss":
                switch ($rel_name) {
                    case "b_p":
                        return array("boss");
                        break;
                }
                break;

            default:
                break;
        }
    }

    public function aumento() {
         $this->salary = $this->salary * 1.1;
       // return $this->salary * 1.1;
        
    }
      public static function menorSalario($pers) {
          $menorSalario=$pers[0]->get('salary');
          $pos=0;
          foreach ($pers as $key => $value){ 
                if($menorSalario>$value->get('salary')){
                    $menorSalario=$value->get('salary');
                    $pos=$key;
                }
            
            }
             return $pos; 
              
          }
           public static function promedioSalario($pers) {
          $promedioSalario=0;
          $numemple=0;
          foreach ($pers as $key => $value){                 
                    $promedioSalario=$promedioSalario+$value->get('salary');                   
                    $numemple=$numemple+1;
            }
           // echo '<br>'.$promedioSalario.'/'.$numemple;
             return $promedioSalario/$numemple; 
              
          }
      
    }
  

?>